﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

<link rel="stylesheet" type="text/css" href="css/index.css">


</head>

<body>

	
	<div class="div1">
		<div class="title">请分别输入三角形的三条边</div>
		<form action="TriangleJudge" method="post"
			onsubmit="return checkNum();">
			<table>
				<tr>
					<td><input name="inputa" id="inputa" type="text"
						autocomplete="off" class="inp" autofocus /> <input name="inputb"
						id="inputb" type="text" autocomplete="off" class="inp" /> <input
						name="inputc" id="inputc" type="text" autocomplete="off"
						class="inp" />
					</td>
				</tr>
				<tr>
					<td class="tdsubmit"><input type="submit"
						value="提交" class="bu1" /> <input type="reset" value="重置"
						class="bu1" /></td>
					
				</tr>
			</table>

		</form>
	</div>
	<div
			class="footerdiv">
			
				Powered By&nbsp;&nbsp;<span id="span1">黄斌 钟志威</span>&nbsp;&nbsp;@2012
				SCAU<br>建议用Google Chrome浏览器打开
			
	</div>
</body>

<script type="text/javascript">
	function checkNum() {
		var str1 = document.getElementById("inputa").value;
		var str2 = document.getElementById("inputb").value;
		var str3 = document.getElementById("inputc").value;
		if ((/\D/.test(str1)) || (/\D/.test(str2)) || (/\D/.test(str3))) { //用正则判断 如果为false   
			//ps:  /\D/  是正则表达式   如果不是数字的话

			document.getElementById("inputa").value = "";//清空文本框

			document.getElementById("inputb").value = "";//清空文本框

			document.getElementById("inputc").value = "";//清空文本框
			alert("只能输入数字");
			document.getElementById("inputa").focus();//获得焦点
			return false;

		}
		if ((str1.length == 0) || (str2.length == 0) || (str3.length == 0)) {//判断输入是否为空

			document.getElementById("inputa").value = "";

			document.getElementById("inputb").value = "";
			document.getElementById("inputc").value = "";
			alert("输入不能为空");
			document.getElementById("inputa").focus();
			return false;
		}
	}
</script>

</html>
